<template>
	<view class="u-page">
		<view class="u-demo-block__content">
		    <view class="u-demo-block__content">
		        <u-row customStyle="margin-bottom: 10px">
		            <u-col span="8">
		                <view class="div1">
							<view class="div2">
								{{patient.name}}
								<u-tag v-bind:text="patient.relation"  shape="circle" class="tag1"></u-tag><br>
								{{patient.number}}
							</view>
							<view style="width: 130rpx;height: 50rpx;float: right;font-size: 4rpx;" @click="cutShow()">
							<view style="width: 50rpx;height: 50rpx;background-color: #000000;margin: 0 auto;"></view>
								切换就诊人
							</view>
						</view>
		            </u-col>
		        </u-row>
		    </view>
		</view>
		<!-- 切换就诊人弹出框 -->
			<u-popup  ref="popup" :show="isCut" mode="bottom" @close="cutDate" class="homepage">
				<view class="popopBox">
					<scroll-view
						scroll-y="true"
						style="height: 50rpx;"
						scroll-with-animation="true"
					>
					</scroll-view>
					<view @click="cutPatient(patient)" class="flex-row wrapper" v-for="patient in patients" style="margin: 20rpx 5rpx;
		padding: 10rpx;background-color: #E5E5E5;">
						<view class="flex-col flex-row wraper-col">
							<view class="flex-row box">
								<view style="float: left;margin-right: 10rpx;">{{patient.name}}</view>
								<view style="padding: 5rpx 15rpx;background-color: #3289FF;display: inline-block;border-radius: 10rpx;">
									<view style="">{{patient.relation}}</view>
								</view>
							</view>
							<view class="u-line-1 text-three">{{patient.number}}</view>
						</view>
					</view>
				</view>
			</u-popup>
	</view>

</template>

<script>
	import {msg} from '@/utils/utils.js'
	import request from '@/utils/requestConfig.js'
	export default{
		data(){
			return{
				isCut:false,
				patient:{},
				patients:[],
				userId:uni.getStorageSync('user').id,

			}
		},
		created() {
			this.findPatientByUserId()
		},
		methods:{
			cutShow(){
				this.isCut=!this.isCut
				this.qie()
			},
			cutDate(){
				this.isCut=!this.isCut
				this.qie()
			},
			cutPatient(patient){
				this.patient=patient
				this.isCut=!this.isCut
				this.qie()
			},
			qie(){

				console.log("切换就诊人")
			},
			/* 获取当前登录用户的病人列表 */
			findPatientByUserId(){
				request.post('/user/user/the-patient/findPatientByUserId',{userId:this.userId},false).then((res)=>{
					
					let tagList=res.data.thePatientList
					this.patients=tagList
					for(let i=0;i<tagList.length;i++){
						let tag=tagList[i]
						if(tag.defaultPerson=="是"){
							this.patient=tag
							//alert(this.patient.hospitalNumber)
							
							// console.error(this.patient)
						}
					}
					
					uni.hideLoading();
				}).catch((error)=>{
					
					console.log(error)
				})
			}
		}
	}
</script>

<style>
.div1{
	width:600rpx;
	background-color: #f3f8ff;
	border:f4f4f5 solid 1rpx;
	border-radius: 15px;
	margin-left:10px;
	margin-top:10px;
	padding: 50rpx;
}
.div2{
	color: #b1b2b4;
	float: left;
}
.tag1{
	display: inline-block;
	color: #3289ff;
	margin-left: 10px;
	
	/* background-color: #3289ff; */
}
</style>
